package com.lrl.security.aspect;


import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

/**
 * @author LRL
 * 切片
 */
@Aspect
@Component
public class TimeAspect {

    @Around("execution(* com.lrl.security.controller.UserController.*(..))")
    public Object handleControllerMethod(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("time aspect start");
        Object[] args = pjp.getArgs();
        for (Object arg: args){
            System.out.println("arg is :"+args);
        }
        Long start = System.currentTimeMillis();
        Object o = pjp.proceed();
        System.out.println("time aspect 耗时:"+(System.currentTimeMillis() - start));
        System.out.println("time aspect start");
        return o;
    }
}
